package com.zxc.controller;

import com.zxc.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
  * @author: zxc
  * @return:
  * @time:  2021/5/19 16:50
  * @description:
  */
@Controller
@RequestMapping("/emp")
public class EmpController {

    @RequestMapping("/login")
    public String login(String ename, String pwd, Model model) {
        System.out.println("ename:" + ename + "----pwd:" + pwd);
        if (ename.equals("admin") && pwd.equals("admin")) {
            System.out.println("登录成功");
            User user = new User();
            user.setName("admin");
            //把数据设置到request作用域中
            model.addAttribute("user", user);
            return "index";
        } else {
            //重定向
            return "redirect:/login.jsp";
//            //转发
//            return "login";
        }
    }
}
